package com.nightpiter.model.objects;

import java.util.ArrayList;

/**
 * @author Cthulhu
 * @author Ilya Shurigyn (honorik@gmail.com)
 * @author Eldar Abusalimov (eldar.abusalimov@gmail.com)
 */
public class Hub {

	private ArrayList<Station> stations = new ArrayList<Station>();

	public void addTransfer(Transfer transfer) {
		Station fromStation = transfer.fromStation;
		Station toStation = transfer.toStation;
		if (!stations.contains(fromStation)) {
			stations.add(fromStation);
			fromStation.setHub(this);
		}
		if (!stations.contains(toStation)) {
			stations.add(toStation);
			toStation.setHub(this);
		}
		transfer.setHub(this);
	}

	public ArrayList<Station> getStations() {
		return stations;
	}
	
	public String toString() {
		String str="-------HUB-------";
		for(Station station: stations) {
			str+=station.getName() + "\n";
		}
		return str;
	}

}
